# -*- coding: utf-8 -*-
"""
Created on Fri Sep 13 11:52:09 2019

@author: Administrator
"""

# 1038 统计同成绩学生
# 思路：读入成绩，找合适数据结构存储成绩，查询某成绩出现的次数
# 因为存储的数据有对应关系，考虑使用dict来存储数据，key为成绩，value为出现次数

# dict的操作
# 增：dict['key'] = value
# 删 del(dict['key'])
# 查：value = dict.get('key')。如果不存在value == None
# 改：先查是否存在，如果存在，则修改，否则新建
def test():
    num = int(input())
    
    raw_data = str(input()).split(' ')
    
    data = [int(ele) for ele in raw_data]

    search = str(input()).split(' ')
    search_num = int(search.pop(0))
    search_data = [int(ele) for ele in search]
    
    scores = dict()
    
    # scores key:成绩，value:该成绩出现的次数
    for i in range(num):
        value = scores.get('%d' % data[i])
        if  value == None:
            scores['%d' % data[i]] = 1
        else:
            scores['%d' % data[i]] = value + 1
    
    result = ''
    # 从scores中查询某个成绩的次数
    for j in range(search_num):
        value = scores.get('%d' % search_data[j])
        if value == None:
            value = 0
        result += '%d ' % value
        
    print(result[0:-1])
    
test()